/*************************************************
** 功能 : 通过输入三角形的三边求得三角形的面积
** 作者 : 杨兰
** 版本 : 2021-10-23 / 15:53
/**************************************************/

#include <iostream>
#include <cstdlib>
#include <windows.h>

using namespace std;

/*----------------------------------*
		Class Definition
 已知三角形三边长度求面积的公式：
		p=(a+b+c)/2
		area=sqrt[p*(p-a)*(p-b)*(p-c)]
 *-----------------------------------*/
double TriangleArea(const double * parray)
{
	double Area = 0;
	double a = 0.0, b = 0.0, c = 0.0;
	a = *parray++;
	b = *parray++;
	c = *parray;
	double p = (a + b + c) / 2;
	Area = sqrt(p*(p - a)*(p - b)*(p - c));
	//cout << "the square of the triangle is ：" << Area<<endl ;
	return Area;
}


/*----------------------------------*
	   Main Function
*-----------------------------------*/

int main()
{
	int m = 0;
	double square;
	double side[3];
	const double * parray = side; //定义一个指向数组的指针
	do
	{
		m++;
		cout << "Please enter the tree sides of a triangle: " << endl; //输入三角形的三边
		for (int i = 0;i < 3;i++)
		{
			cin >> side[i];
		}
		square = TriangleArea(parray);
		cout << "the square of the triangle is:" << square << endl;
	} while (m < 10);
	system("pause");

	return 0;
}